package com.omybug.study.entity;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author: omybug
 * @date: 18/9/16 21:55
 */
@Component
public class People implements InitializingBean, DisposableBean, BeanPostProcessor {
    private Integer age;

    private String name;

    public People(){
        System.out.println("People construct");
    }

    @Override
    public String toString() {
        return "name : " + getName() + " age : " + getAge();
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("people.destroy");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("people.afterPropertiesSet");
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("people.postProcessBeforeInitialization");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("people.postProcessAfterInitialization");
        return bean;
    }
}
